import 'uno.css';
import 'normalize.css';
import '@/styles/index.scss';
import 'dayjs/locale/zh-cn'; // 如果你需要中文本地化
import 'dayjs/plugin/customParseFormat';
import 'uno.css';
import 'normalize.css';
import '@/styles/index.scss';

import { ReactKeycloakProvider } from '@react-keycloak/web';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import weekday from 'dayjs/plugin/weekday';
import Keycloak from 'keycloak-js';
import { createRoot } from 'react-dom/client';
import { RouterProvider } from 'react-router-dom';
import { RecoilRoot } from 'recoil';
import RecoilNexus from 'recoil-nexus';

import { colors } from './config/theme';
import { router } from './router';
dayjs.extend(weekday);
dayjs.extend(localeData);

const keycloakOpts = {
  url: 'https://kc-dev.openjobsus.com',
  realm: 'craftflow',
  clientId: 'fronted'
};

const keyCloak = new Keycloak(keycloakOpts);

createRoot(document.getElementById('app')!).render(
  <ReactKeycloakProvider authClient={keyCloak} initOptions={{ responseMode: 'query', onLoad: 'login-required' }}>
    <RecoilRoot>
      <RecoilNexus />
      <ConfigProvider
        locale={zhCN}
        componentSize="middle"
        theme={{
          token: {
            colorPrimary: colors.primary[500]
          }
        }}>
        <RouterProvider router={router} />
      </ConfigProvider>
    </RecoilRoot>
  </ReactKeycloakProvider>
);
